package tech.aistar.day04.ses;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet(urlPatterns = "/session/get")
public class SessionGetController extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        PrintWriter out = resp.getWriter();

        //从session作用域中获取数据 -根据key来获取
        HttpSession session = req.getSession();
        String remark = (String) session.getAttribute("remark");

        out.println("remark:"+remark);
    }
}
